home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- #
- # Copyright 2002, Silicon Graphics, Inc.
- # All Rights Reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # --------------
- # valid_helpmaps
- # --------------
- # syntax:
- #
- # valid_helpmaps <sgml_file> <helpmap_dir>
- #
-
- $SGML = $ARGV[0];
- $DIR = $ARGV[1];
- if ($SGML eq '' || $DIR eq '') {
- &usage("SGML file (${SGML}) or helpmap directory (${DIR}) not specified");
- }
-
- if (!(-f $SGML) || !(-d $DIR)) {
- &usage("SGML file (${SGML}) or helpmap directory (${DIR}) not found");
- }
-
-
- $VALID_HELPMAPS = '';
-
- my(@hm, @hl, @pts) = ();
- my($bAdd) = 0;
-
- @hm = split(/\n/, `(find ${DIR} -type f -print)`);
-
- foreach $f (@hm) {
-
- $bAdd = 0;
-
- open(HELPMAP, "${f}") || &usage("Cannot open helpmap: ${f}");
- @hl = <HELPMAP>;
- close(HELPMAP);
-
- # check helpmap points, compare to sgml file(s)
- #
- foreach $s (@hl) {
-
- if ($s !~ /\;/) {
- next;
- }
-
- @pts = split(/\;/, $s);
-
- # we go until we find a valid point and then get out.
- # at some point, we can (and probably should) do more here...
- #
- if ($pts[1] =~ /^HREF/i || $pts[4] =~ /\.htm/ || $pts[4] =~ /^\#/) {
- $bAdd = 1;
- } else {
-
- $cmd = "egrep \"(HELPID\|helpid) \?= \?\\\"" .
- $pts[4] . "\\\"\" ${SGML}";
-
- open(CMD, "$cmd |") || &usage("Cannot start command: ${cmd}");
- while (<CMD>) {
- chop;
- if ($_ ne '') {
- $bAdd = 1;
- last;
- }
- }
- close(CMD);
- }
-
- if ($bAdd) {
- $VALID_HELPMAPS .= "${f} ";
- last;
- }
- }
- }
-
- print "${VALID_HELPMAPS}\n";
- exit 0;
-
-
- sub usage {
-
- my($err) = @_;
- print "\nusage: valid_helpmaps <sgml_file> <helpmap_dir>\n",
- ($err ne '' ? "${err}\n" : '');
- exit(-1);
- }
-
-